[id].vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <!-- <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1> -->
  6. <!-- 头部 -->
  7. <templateHead></templateHead>
  8. <!-- 菜单 -->
  9. <templateMenu></templateMenu>
  10. <!-- 商圈详情 -->
  11. <div class="topicInfoBox">
  12. <div class="inner">
  13. <!-- 详情头部 -->
  14. <div class="infoHead">
  15. <div class="left">
  16. <div class="userInfo left">
  17. <el-badge value="楼主" class="item" type="warning">
  18. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  19. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  20. alt="">
  21. </el-badge>
  22. <span>{{ dataInfo.nickname }}</span>
  23. </div>
  24. <div class="headContent left">
  25. <h2>{{ dataInfo.title }}</h2>
  26. <p v-show="dataInfo.group_name">
  27. 群聊:
  28. <span>{{ dataInfo.group_name }}</span>
  29. <button @click="joinGroup">加入群聊</button>
  30. </p>
  31. </div>
  32. </div>
  33. <div class="right">
  34. <div class="one">
  35. <span v-for="item in typeList" :key="index">
  36. <span v-if="dataInfo.type == item.value" class="one">{{ item.label }}</span>
  37. </span>
  38. </div>
  39. <p>{{ dataInfo.updated_at }}</p>
  40. </div>
  41. </div>
  42. <!-- 详情页 文本+图片 -->
  43. <div class="infoContent" v-show="dataInfo.content">
  44. <div v-html="dataInfo.content"></div>
  45. </div>
  46. <div class="infoContent1" v-show="!dataInfo.content">
  47. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  48. <span>可以看看大家的互动哦~</span>
  49. </div>
  50. <!-- 详情页评论 -->
  51. <div class="comment">
  52. <h3>评论</h3>
  53. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  54. <div class="left">
  55. <img v-if='item.avatar' :src="item.avatar" alt="">
  56. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  57. <span class="name">{{ item.nickname }} : </span>
  58. </div>
  59. <div class="center">
  60. <span class="context">{{ item.content }}</span>
  61. </div>
  62. <div class="right">
  63. <span class="time">{{ item.created_at }}</span>
  64. <!-- <span>回复</span> -->
  65. </div>
  66. </div>
  67. <div class="comment_empty" v-show="page_total == 0">
  68. <img src="../../public/topic/message_empty.png" alt="">
  69. <span>暂无评论</span>
  70. </div>
  71. </div>
  72. <!-- 分页 -->
  73. <div class="paginationBox" v-show="page_total != 0">
  74. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  75. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  76. </div>
  77. </div>
  78. </div>
  79. <div class="message">
  80. <div class="inner">
  81. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  82. <button class="btn" @click="addReply">确定</button>
  83. </div>
  84. </div>
  85. <!-- 页面底部 -->
  86. <!-- <HomeFoot1></HomeFoot1> -->
  87. <templateFoot></templateFoot>
  88. </div>
  89. </template>
  90. <script setup>
  91. //1.引用模块 start ---------------------------------------->
  92. //使用ref和reactive动态变量
  93. import { ref, reactive, onMounted } from 'vue'
  94. import { useRoute } from 'vue-router';
  95. //使用官方ssr请求模块
  96. import { useNuxtApp, useFetch } from '#app'
  97. //使用element-plus组件
  98. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  99. // axios请求
  100. const nuxtApp = useNuxtApp();
  101. const axios = nuxtApp.$axios;
  102. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  103. //1.引用模块 end ---------------------------------------->
  104. // 定义响应式数据
  105. const seoData = ref({
  106. title: '商圈',
  107. description: '默认描述',
  108. keywords: '默认关键词',
  109. image: 'https://example.com/default-image.jpg'
  110. });
  111. // 在 onMounted 钩子中获取数据
  112. onMounted(() => {
  113. seoData.value.title = '商圈';
  114. seoData.value.description = '默认描述';
  115. seoData.value.keywords = '默认关键词';
  116. })
  117. //2.页面数据 start ---------------------------------------->
  118. const dataInfo = ref({})
  119. const groupId = useState("groupId", () => '')
  120. const replyList = useState("replyList", () => []) //评论列表
  121. //分页
  122. const page = ref(1)
  123. const pageSize = ref(5)
  124. let page_total = ref(0)
  125. const content = ref('')
  126. //2.页面数据 end ---------------------------------------->
  127. //3.获取商圈详情 start ---------------------------------------->
  128. const route = useRoute();
  129. const id = route.params.id; // 获取传递的 id 参数
  130. //页码发生改变
  131. const changePage = (val) => {
  132. console.log(val);
  133. page.value = val
  134. getTopicReply()
  135. }
  136. // 商圈信息
  137. const getTopicInfo = () => {
  138. let data = new FormData()
  139. data.append('id', id)
  140. axios.post('chat/getTopicInfo', data).then(res => {
  141. console.log('商圈信息', res);
  142. dataInfo.value = res.data
  143. groupId.value = res.data.group_id
  144. console.log(groupId.value);
  145. })
  146. }
  147. // 回复商圈 列表
  148. const getTopicReply = () => {
  149. let data = new FormData()
  150. data.append('id', id)
  151. data.append('page', page.value)
  152. data.append('page_size', pageSize.value)
  153. axios.post('chat/getTopicReply', data).then(res => {
  154. console.log('回复商圈列表 ', res);
  155. replyList.value = res.data.data
  156. // page_total.value = res.data.total
  157. page_total.value = res.data.total
  158. console.log("replyList", replyList);
  159. })
  160. }
  161. //5.获取分类和状态 start ---------------------------------------->
  162. const listData = useState("listData", () => [])//商圈列表
  163. const typeList = useState("typeList", () => [])//商圈分类
  164. const topicType = () => {
  165. axios.post('/chat/topicType').then(response => {
  166. console.log(111222333)
  167. console.log(response.data);
  168. // console.log(1);
  169. typeList.value = response.data;
  170. })
  171. }
  172. const topicStatus = () => {
  173. axios.post('chat/topicStatus').then(response => {
  174. console.log(response);
  175. })
  176. }
  177. onMounted(() => {
  178. getTopicInfo(); //商圈信息
  179. getTopicReply(); //回复商圈列表
  180. topicType();
  181. topicStatus();
  182. })
  183. //加入群聊
  184. const joinGroup = () => {
  185. ElMessageBox.confirm(
  186. '加入群聊后,页面跳转至后台群聊页面',
  187. '是否加入群聊?',
  188. {
  189. confirmButtonText: '是',
  190. cancelButtonText: '否',
  191. center: true,
  192. }
  193. ).then(() => {
  194. console.log('groupId.value', groupId.value);
  195. let data = new FormData()
  196. data.append('group_id', groupId.value)
  197. axios.post('chat/joinGroup', data).then(res => {
  198. console.log('加入群聊 ', res);
  199. if (res.code == 0 && res.message !== '已加入群') {
  200. ElMessage.error(res.message)
  201. } else if (res.code == 0 && res.message == '已加入群') {
  202. ElMessage({
  203. message: res.message,
  204. type: 'success',
  205. })
  206. setTimeout(() => {
  207. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  208. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  209. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  210. }, 1000)
  211. } else if (res.code == 200) {
  212. ElMessage({
  213. message: '加入成功',
  214. type: 'success',
  215. })
  216. setTimeout(() => {
  217. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  218. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  219. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  220. }, 1000)
  221. }
  222. })
  223. }).catch(() => {
  224. ElMessage({
  225. type: 'error',
  226. message: '已取消',
  227. })
  228. })
  229. }
  230. // 回复商圈
  231. const addReply = () => {
  232. let data = new FormData()
  233. data.append('id', id)
  234. data.append('content', content.value)
  235. axios.post('chat/addReply', data).then(res => {
  236. console.log('回复商圈 ', res);
  237. if (res.code == 0) {
  238. ElMessage.error(res.message)
  239. getTopicReply();
  240. } else if (res.code == 200) {
  241. ElMessage({
  242. message: '回复成功',
  243. type: 'success',
  244. })
  245. content.value = ''
  246. getTopicReply();
  247. }
  248. })
  249. }
  250. //3.获取商圈详情 end ---------------------------------------->
  251. //自助建站 start---------------------------------------->
  252. //1.获得自助建站头部底部
  253. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  254. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  255. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  256. //2.获得pinia源
  257. import { useTemplateBaseStore } from '@/stores/templateBase'
  258. const templateBaseStore = useTemplateBaseStore()
  259. //3.获得该页的皮肤id
  260. const skinId = ref("")
  261. const websiteId = ref("")
  262. //4.获得站点基本信息
  263. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  264. method: 'GET',
  265. query: {
  266. 'link_textnum':24,
  267. 'link_imgnum':18,
  268. 'link_footnum':4
  269. },
  270. });
  271. if (responseStatus.code == 200) {
  272. if(responseStatus.data.website_foot.foot_info.status == 1){
  273. //网站模板已停用,直接转入404页面
  274. navigateTo('/error?findPage=index')
  275. }else{
  276. //4.1设置站点基本信息
  277. templateBaseStore.setWebSiteInfo(responseStatus.data)
  278. websiteId.value = responseStatus.data.website_head.id;
  279. //4.2设置皮肤id
  280. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  281. //4.3设置seo
  282. useSeoMeta({
  283. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  284. meta: [
  285. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 },
  286. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 }
  287. ]
  288. });
  289. }
  290. }
  291. //5.获得广告池
  292. const adData = ref([]);
  293. const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
  294. method: 'GET',
  295. query: {},
  296. });
  297. if (adResponseStatus.code == 200) {
  298. templateBaseStore.setAdList(adResponseStatus.data)
  299. adData.value = adResponseStatus.data;
  300. }
  301. //6.是否使用了搜索页
  302. const response = await requestDataPromise('/client/indexData', {
  303. method: 'POST',
  304. body: {
  305. 'website_id':websiteId.value,
  306. 'getpage':'article'
  307. },
  308. });
  309. if(response.code == 200){
  310. //是否启用搜索功能
  311. templateBaseStore.setIsSearch(response.data.isSearch)
  312. }
  313. //自助建站 end---------------------------------------->
  314. </script>
  315. <style lang="less" scoped>
  316. .topicInfoBox {
  317. .inner {
  318. width: 1200px;
  319. margin: 0 auto;
  320. //信息头部
  321. .infoHead {
  322. height: 200px;
  323. padding: 65px 0 60px 40px;
  324. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  325. box-sizing: border-box;
  326. >.left {
  327. .userInfo {
  328. margin-right: 90px;
  329. .item {
  330. margin-top: -5px;
  331. margin-right: -5px;
  332. :deep(.el-badge__content.is-fixed) {
  333. position: absolute;
  334. right: calc(1px + var(--el-badge-size) / 2);
  335. top: 0;
  336. transform: translateY(-31%) translateX(79%);
  337. z-index: var(--el-index-normal);
  338. }
  339. img {
  340. width: 66px;
  341. height: 66px;
  342. vertical-align: middle;
  343. border-radius: 50%;
  344. }
  345. }
  346. span {
  347. margin-left: 15px;
  348. font-family: Microsoft YaHei, Microsoft YaHei;
  349. font-weight: 400;
  350. font-size: 18px;
  351. color: #333333;
  352. }
  353. }
  354. .headContent {
  355. h2 {
  356. width: 750px;
  357. height: 56px;
  358. line-height: 28px;
  359. display: -webkit-box;
  360. -webkit-box-orient: vertical;
  361. -webkit-line-clamp: 2;
  362. overflow: hidden;
  363. text-overflow: ellipsis;
  364. word-break: break-all;
  365. font-family: Microsoft YaHei, Microsoft YaHei;
  366. font-weight: bold;
  367. font-size: 20px;
  368. color: #333333;
  369. margin-bottom: 26px;
  370. }
  371. >p {
  372. font-family: Microsoft YaHei, Microsoft YaHei;
  373. font-weight: 400;
  374. font-size: 16px;
  375. color: #333333;
  376. button {
  377. width: 86px;
  378. height: 32px;
  379. background-color: #028e21;
  380. color: #fff;
  381. border: none;
  382. margin-left: 100px;
  383. }
  384. }
  385. }
  386. }
  387. >.right {
  388. position: relative;
  389. div {
  390. position: absolute;
  391. right: 0;
  392. top: 0;
  393. width: 71px;
  394. height: 32px;
  395. line-height: 32px;
  396. text-align: center;
  397. background-color: #d9f0d6;
  398. margin-bottom: 29px;
  399. font-family: Microsoft YaHei, Microsoft YaHei;
  400. font-weight: 400;
  401. font-size: 16px;
  402. color: #33B023;
  403. }
  404. .one {
  405. color: #FFAA33;
  406. background-color: #fbebd5;
  407. }
  408. .two {
  409. color: #33B023;
  410. background-color: #d5ecd2;
  411. }
  412. .three {
  413. color: #666;
  414. background-color: #ebebeb;
  415. }
  416. p {
  417. width: 150px;
  418. text-align: right;
  419. position: absolute;
  420. top: 62px;
  421. right: 0;
  422. }
  423. }
  424. }
  425. // 有详情信息
  426. .infoContent {
  427. width: 1196px;
  428. overflow: hidden;
  429. padding: 30px 46px;
  430. font-family: Microsoft YaHei, Microsoft YaHei;
  431. font-size: 20px;
  432. line-height: 40px;
  433. box-sizing: border-box;
  434. div {
  435. word-wrap: break-word;
  436. /* 强制长单词或 URL 换行 */
  437. overflow-wrap: break-word;
  438. /* 现代推荐用法,等同于 word-wrap */
  439. white-space: pre-wrap;
  440. /* 保留空白字符并允许自动换行 */
  441. word-break: break-all;
  442. /* 强制在任意字符处换行 */
  443. }
  444. }
  445. .leftBottom::v-deep p {
  446. width: 1200px;
  447. white-space: pre-wrap;
  448. }
  449. //没有详情信息
  450. .comment_empty,
  451. .infoContent1 {
  452. height: 300px;
  453. line-height: 260px;
  454. text-align: center;
  455. img {
  456. width: 78px;
  457. height: 78px;
  458. vertical-align: -25px;
  459. vertical-align: middle;
  460. margin-right: 20px;
  461. }
  462. span {
  463. font-family: Microsoft YaHei, Microsoft YaHei;
  464. font-weight: bold;
  465. font-size: 26px;
  466. color: #CCCCCC;
  467. }
  468. }
  469. //评论
  470. .comment {
  471. h3 {
  472. height: 100px;
  473. padding-top: 30px;
  474. box-sizing: border-box;
  475. border-bottom: 1px solid #E1E1E1;
  476. font-family: Microsoft YaHei, Microsoft YaHei;
  477. font-weight: 400;
  478. font-size: 22px;
  479. color: #000000;
  480. }
  481. .commentList {
  482. border: 1px solid #E1E1E1;
  483. background-color: #fafafa;
  484. margin-top: 20px;
  485. padding: 30px 30px;
  486. box-sizing: border-box;
  487. display: flex;
  488. align-items: flex-start;
  489. justify-content: space-between;
  490. .left {
  491. width: 400px;
  492. margin-right: 30px;
  493. display: flex;
  494. justify-content: space-between;
  495. img {
  496. width: 52px;
  497. height: 52px;
  498. border-radius: 50%;
  499. vertical-align: middle;
  500. margin-right: 15px;
  501. }
  502. span {
  503. height: 52px;
  504. line-height: 22px;
  505. padding-top: 10px;
  506. }
  507. .name {
  508. width: 120px;
  509. font-family: Microsoft YaHei, Microsoft YaHei;
  510. font-weight: 400;
  511. font-size: 16px;
  512. color: #333333;
  513. margin-right: 15px;
  514. white-space: nowrap;
  515. overflow: hidden;
  516. text-overflow: ellipsis;
  517. display: block;
  518. }
  519. }
  520. .center {
  521. .context {
  522. width: 700px;
  523. margin-right: 40px;
  524. display: -webkit-box;
  525. -webkit-box-orient: vertical;
  526. -webkit-line-clamp: 2;
  527. overflow: hidden;
  528. text-overflow: ellipsis;
  529. word-break: break-all;
  530. font-family: Microsoft YaHei, Microsoft YaHei;
  531. font-weight: bold;
  532. font-size: 16px;
  533. color: #333333;
  534. }
  535. }
  536. .right {
  537. .time {
  538. display: block;
  539. width: 200px;
  540. font-family: Microsoft YaHei, Microsoft YaHei;
  541. font-weight: 400;
  542. font-size: 16px;
  543. color: #999999;
  544. margin-right: 30px;
  545. }
  546. span {
  547. font-family: Microsoft YaHei, Microsoft YaHei;
  548. font-weight: 400;
  549. font-size: 16px;
  550. color: #333333;
  551. }
  552. }
  553. }
  554. }
  555. }
  556. }
  557. //评论回复
  558. .message {
  559. width: 1200px;
  560. margin: 0 auto 20px;
  561. padding: 0px 25px;
  562. box-sizing: border-box;
  563. height: 145px;
  564. line-height: 145px;
  565. background-color: #ecf5ee;
  566. .inner {
  567. .messageInput {
  568. width: 1000px;
  569. height: 67px;
  570. outline: none;
  571. border: 1px solid #E1E1E1;
  572. background-color: #fafafa;
  573. font-family: Microsoft YaHei, Microsoft YaHei;
  574. font-weight: 400;
  575. font-size: 18px;
  576. color: #666;
  577. padding: 0 20px;
  578. box-sizing: border-box;
  579. }
  580. .btn {
  581. width: 115px;
  582. height: 40px;
  583. border: none;
  584. background-color: #028e21;
  585. color: #fff;
  586. border-radius: 6px;
  587. margin-left: 36px;
  588. font-family: Microsoft YaHei, Microsoft YaHei;
  589. font-weight: 400;
  590. font-size: 16px;
  591. }
  592. }
  593. }
  594. //分页
  595. .paginationBox {
  596. display: flex;
  597. justify-content: center;
  598. margin-top: 60px;
  599. margin-bottom: 90px;
  600. // 鼠标移入后字体颜色
  601. :deep(.el-pagination:hover) {
  602. color: #139609;
  603. }
  604. :deep(.el-pagination.is-background .btn-next),
  605. :deep(.el-pagination.is-background .btn-prev) {
  606. width: 70px;
  607. height: 34px;
  608. margin: 0px 10px;
  609. border-radius: 4px;
  610. }
  611. :deep(.el-pagination.is-background .el-pager li) {
  612. margin: 0px 10px;
  613. width: 38px;
  614. height: 34px;
  615. border-radius: 4px;
  616. }
  617. :deep(.el-pagination.is-background .btn-next.is-active),
  618. :deep(.el-pagination.is-background .btn-prev.is-active),
  619. :deep(.el-pagination.is-background .el-pager li.is-active) {
  620. background-color: #028e21;
  621. color: #fff;
  622. }
  623. }
  624. </style>